/**
 * @brief SPI driver header
 * @author Gilad Avidov
 */
#ifndef SPI_H_INCLUDED
#define SPI_H_INCLUDED

extern volatile unsigned char spi_data;
extern volatile bit spi_data_is_done;

typedef enum {
    SPI_CLK_DIV_BY_2   = 0x0,
    SPI_CLK_DIV_BY_4   = 0x1,
    SPI_CLK_DIV_BY_8   = 0x2,
    SPI_CLK_DIV_BY_16  = 0x3,
    SPI_CLK_DIV_BY_32  = 0x4,
    SPI_CLK_DIV_BY_62  = 0x5,
    SPI_CLK_DIV_BY_128 = 0x6,
} spi_baud_rate_divisor_t ;

void spi_config(bit cpol, bit _CPHA, spi_baud_rate_divisor_t baud);

void spi_write(unsigned char byte);

unsigned char spi_read();

#endif // SPI_H_INCLUDED
